import request from '../api';

export const listLesson = async (token) => {
  const res = await request.request({
    url: `listLesson?token=${token}`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });

  return res.data;
};

export const addLesson = async (token, course) => {
  const res = await request.request({
    url: `addLesson?token=${token}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      ...course
    }
  });

  return res.data;
};


export const saveLesson = async (token, course) => {
  const res = await request.request({
    url: `saveLesson?token=${token}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      ...course
    }
  });

  return res.data;
};

export const downLesson = async (token, id) => {
  const res = await request.request({
    url: `downLesson?token=${token}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      id
    }
  });

  return res.data;
};

export const listLessonExchange = async (token) => {
  const res = await request.request({
    url: `listLessonExchage?token=${token}`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    }
  });
  return res.data;
};

export const setLessonExchange = async (token, id, status) => {
  const res = await request.request({
    url: `setLessonExchange?token=${token}`,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      id,
      status
    }
  });
  return res.data;
};

export const listLessonType = async (token) => {
  const res = await request.request({
    url: `listLessonType?token=${token}`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    },
  });
  return res.data
};
